package lab2;

import java.io.File;
import java.util.Scanner;


public class TableBuilderDemo {
    static final String[] tableTypes = {"","JTable_Table","GridLayout_Table","GridBagLayout_Table"};
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        boolean working = true;
        while(true) {
            System.out.println("******请选择表格样式*********");
            System.out.println("1*****JTable_Table*********");
            System.out.println("2*****GridLayout_Table*********");
            System.out.println("3*****GridBagLayout_Table*********");
            String input = sc.next();
            try {
                working = !(new TableBuilderDemo()).demo(tableTypes[Integer.parseInt(input)]);
            }catch(Exception ex) {
                ex.printStackTrace();
                System.out.println("只能输入：1,2,3中之一！");
            }
        }
    }

    /**
     * Client code perspective.
     * @return
     */
    public boolean demo(String class_name) {
        Builder builder = BuilderFactory.getBuilder(class_name);
        TableDirector director = new TableDirector(builder);
        director.build();
        return true;
    }

}

